package cn.itsource.feignclient.clientfactory;

import cn.itsource.domain.User;
import cn.itsource.feignclient.UserFeignClient;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;


@Component
public class UserFeignClientFallBack implements FallbackFactory<UserFeignClient> {

    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User getUser(Long id) {
                throwable.printStackTrace();
                return new User(id,"OpenFeign 熔断","用户服务不可用！");
            }
        };
    }
}
